package manage.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import manage.dao.AttendancesubMapper;
import manage.model.Attendancesub;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AttendancesubServiceImpl {
    @Autowired
    private AttendancesubMapper attendancesubMapper;

    public PageInfo<Attendancesub> selectAll(String page, String limit) {

        int pu = Integer.parseInt(page);
        int li = Integer.parseInt(limit);

        PageHelper.startPage(pu,li);
        List<Attendancesub> list = attendancesubMapper.selectAll();
        PageInfo<Attendancesub> pageInfo = new PageInfo<Attendancesub>(list);
        return pageInfo;
    }

    public String insert(Attendancesub record) {

        int i = attendancesubMapper.insert(record);
        if(i>0)
            return "success";
        return "fail";
    }

    public String del(String id) {
        int i = attendancesubMapper.deleteByPrimaryKey(id);
        if(i>0)
            return "success";
        return "fail";
    }

    public Attendancesub select(String id) {
        return attendancesubMapper.selectByPrimaryKey(id);
    }
    public String update(Attendancesub record){
        if(attendancesubMapper.updateByPrimaryKey(record)>0)
            return "success";
        return "fail";
    }
    
}
